package me.bincker.formwork.web.core.exception

import org.springframework.http.HttpStatus
import java.lang.Exception

/**
 * 系统总异常类
 */
open class WebException: Exception {
    val httpStatus: HttpStatus
    val responseMessage: String
    constructor(httpStatus: HttpStatus) : this(httpStatus, "发生了错误，请稍后再试！")
    constructor(httpStatus: HttpStatus, cause: Throwable) : this(httpStatus, cause, "发生了错误，请稍后再试！")
    constructor(httpStatus: HttpStatus, cause: Throwable, responseMessage: String) : this(httpStatus, cause.message ?: responseMessage, responseMessage, cause)
    constructor(httpStatus: HttpStatus, message: String) : this(httpStatus, message, message)
    constructor(httpStatus: HttpStatus, message: String, responseMessage: String) : this(httpStatus, message, responseMessage, null)
    constructor(httpStatus: HttpStatus, message: String, responseMessage: String, cause: Throwable?) : super(message, cause){
        this.httpStatus = httpStatus
        this.responseMessage = responseMessage
    }
}
